''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：alibaba_base.py
#日期：2023-7-15
#备注：查询和处理数据库基础数据
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

from pacong.stock.stock_config import db,cursor
from pycacho.cachobase.logger import Logger

logger = Logger("alibaba_base").get_log()

# 查询一个字段
def select_one(field_one,field_two,table):
    sql = "select %s,%s from %s;"%(field_one,field_two,table)
    cursor.execute(sql)
    results = cursor.fetchall()
    return results

# 按条件查询一个字段
def select_condition_one(field,table,c_field,condition):
    sql = "select {0} from {1} where {2} LIKE '%{3}%';".format(field,table,c_field,condition)
    cursor.execute(sql)
    results = cursor.fetchall()
    return results

# 按条件查询字段
def select_condition(condition):
    sql = "select id,groupRemark from alibaba_product where subject LIKE '%{0}%';".format(condition)
    cursor.execute(sql)
    results = cursor.fetchall()
    return results

if __name__ == '__main__':
    #select_one('keywordId', 'alibaba_keywords')
    select_condition('protectores de celulares')